package com.itheima.afternoon;

import java.lang.reflect.Field;

public class Demo05 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchFieldException, NoSuchMethodException {
        Class clazz = Class.forName("com.itheima.afternoon.Student");
        //method1(clazz);
    }

    private static void method1(Class clazz) throws InstantiationException, IllegalAccessException, NoSuchFieldException {
        Student student = (Student) clazz.newInstance();
        Field name = clazz.getField("name");
        Field stuId = clazz.getField("stuId");
        Field age = clazz.getField("age");
        name.set(student,"张三");
        stuId.set(student,"10001");
        age.set(student,23);
        System.out.println(student);

        String name1 = (String) name.get(student);
        System.out.println(name1);
    }
}
